package com.hxzy.module.admin.fallback;

import com.hxzy.common.enums.AckCode;
import com.hxzy.common.web.resp.R;
import com.hxzy.module.admin.AdminFeignClient;
import com.hxzy.module.admin.resp.AccountDetailResp;
import feign.hystrix.FallbackFactory;
import lombok.extern.log4j.Log4j2;
import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
import org.springframework.stereotype.Component;

/**
 * feign失败了  熔断
 */
@Component
@Log4j2
public class AdminFeignClientFallback implements FallbackFactory<AdminFeignClient> {

    @Override
    public AdminFeignClient create(Throwable throwable) {
        log.error(throwable);
        return new AdminFeignClientImpl();
    }


    /**
     * 内部类来实现接口
     */
    class AdminFeignClientImpl implements AdminFeignClient{

        @Override
        public R<AccountDetailResp> adminAccountFindById(String accountId) {

            return R.build(AckCode.SYSTEM_DATA_FAIL);
        }
    }
}
